package net.zoneland.knowledge.model;

import java.util.Date;

import net.zoneland.knowledge.utils.DateHelper;

/**
 * @version v1.0
 * @ClassName: ResponseResult
 * @Description: 统一请求信息返回数据类
 * @Author: Pbody
 * @Date: 2020/3/11 13:55
 */
public class ResponseResult<T> {
    public ResponseResult(final T data) {
        this.data = data;
    }

    public ResponseResult() {
    }

    /**
     * 失败编码.
     */
    public static final String FAILED_RESULT = "0";
    /**
     * 认证失败编码.
     */
    public static final String ACCESS_FAILED_RESULT = "403";
    /**
     * “1”成功，“0”，失败.
     */
    private String result = "1";
    /**
     * result为“1”时返回“成功”；为“0”时返回“具体错误信息描述”.
     */
    private String message = "成功";
    /**
     * 返回时间.
     */
    private String resTime = DateHelper.getDateTime(new Date());
    /**
     * 返回时间.
     */
    private T data;

    /**
     * Gets the value of result.
     *
     * @return the value of result
     */
    public String getResult() {
        return result;
    }

    /**
     * Sets the result.
     *
     * <p>You can use getResult() to get the value of result</p>
     *
     * @param result result
     */
    public void setResult(final String result) {
        this.result = result;
    }

    /**
     * Gets the value of message.
     *
     * @return the value of message
     */
    public String getMessage() {
        return message;
    }

    /**
     * Sets the message.
     *
     * <p>You can use getMessage() to get the value of message</p>
     *
     * @param message message
     */
    public void setMessage(final String message) {
        this.message = message;
    }

    /**
     * Gets the value of resTime.
     *
     * @return the value of resTime
     */
    public String getResTime() {
        return resTime;
    }

    /**
     * Sets the resTime.
     *
     * <p>You can use getResTime() to get the value of resTime</p>
     *
     * @param resTime resTime
     */
    public void setResTime(final String resTime) {
        this.resTime = resTime;
    }

    /**
     * Gets the value of data.
     *
     * @return the value of data
     */
    public T getData() {
        return data;
    }

    /**
     * Sets the data.
     *
     * <p>You can use getData() to get the value of data</p>
     *
     * @param data data
     */
    public void setData(final T data) {
        this.data = data;
    }

    /**
     * toString.
     **/
    @Override
    public String toString() {
        return "ResponseResult [result=" + result + ", message=" + message + ", data=" + data + "]";
    }

    public ResponseResult(final String message, final String resTime, final T data) {
        this.message = message;
        this.resTime = resTime;
        this.data = data;
    }

    public ResponseResult(final String message, final T data) {
        this.message = message;
        this.data = data;
    }
}
